import React, { Component } from "react";
import { connect } from "dva";

class Test extends Component {
  inc=()=>{
    this.props.dispatch({
      type: 'example/inc',
      payload: 2
    })
  }
  incAsync=()=>{
    this.props.dispatch({
      type: 'example/incAsync'
    })
  }
  render() {
    return (
      <div>test---
        <span>{this.props.n}</span>
        <button onClick={this.inc}>+</button>
        <button onClick={this.incAsync}>+</button>
      </div>
    )
  }
}

const mapStateToProps = (state)=>{
  return {
    n: state.example.n
  }
}
export default connect(mapStateToProps)(Test);
